﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace RecruitStudents.Client.DAL
{
    public class DALConsult : Base.BaseService
    {
        public DataTable GetWaitResponseProblemList(string strCondition)
        {
            string sql = @"
                            select 
                                A.ID,
                                A.ConsultTypeName,
                                A.CreateDate,
                                case when A.IsTop = '1' then '是' else '否' end as IsTop,
                                case when A.IsReply = '1' then '是' else '否' end as IsReply,
                                case when A.IsPublic = '1' then '公开' else '不公开' end as IsPublic,
                                case when B.IsFee = '1' then '是' else '否' end as IsFee,
                                A.ReplyDate,
                                A.UsersNickName,
                                A.ConsultResorce,
                                B.Name as MsgUsersName,
                                B.Mobile
                            from TB_ConsultTitle A
                            left join TB_ConsultUsers B ON A.UsersID = B.ID
                            where A.UsersNickName != '超级管理员' and  A.State = '1'  and A.IsReply != '1' {0}
                            order by CreateDate 
                        ";
            sql = string.Format(sql, strCondition);
            return base.GetTable(sql);
        }

        public DataTable GetRepliedProblemList(string strJson)
        {
            string sql = @"
                            select top 30
                                A.ID,
                                A.ConsultTypeName,
                                A.CreateDate,
                                case when A.IsTop = '1' then '是' else '否' end as IsTop,
                                case when A.IsReply = '1' then '是' else '否' end as IsReply,
                                case when A.IsPublic = '1' then '公开' else '不公开' end as IsPublic,
                                case when B.IsFee = '1' then '是' else '否' end as IsFee,
                                A.ReplyDate,
                                A.UsersNickName,
                                A.ConsultResorce,
                                B.Name as MsgUsersName,
                                B.Mobile
                            from TB_ConsultTitle A
                            left join TB_ConsultUsers B ON A.UsersNickName = B.NickName
                            where A.UsersNickName != '超级管理员' and A.IsReply = '1'   {0} 
                            order by ReplyDate desc
                        ";
            sql = string.Format(sql, strJson);
            return base.GetTable(sql);

        }
    }
}
